package org.fuys.coder.domain.favorites.service.impl;

import org.fuys.coder.common.entity.Pair;
import org.fuys.coder.common.entity.PageDTO;
import org.fuys.coder.domain.favorites.model.vo.FavoritesIntroVO;
import org.fuys.coder.domain.favorites.repository.IFavoriteRepository;
import org.fuys.coder.domain.favorites.repository.IUserFavoriteRepository;
import org.fuys.coder.domain.favorites.service.IFavoriteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.domain.favorites.service.impl
 * @className: FavoriteServiceImpl
 * @author: WangJing
 * @description: 收藏服务实现类
 * @date: 2024/9/3 15:06
 * @version: 1.0
 */

@Service
public class FavoriteServiceImpl implements IFavoriteService {

    @Resource
    private IFavoriteRepository favoriteRepository;

    @Resource
    private IUserFavoriteRepository userFavoriteRepository;


    @Override
    public long createNewEmptyFavorite() {
        return favoriteRepository.createNewEmptyFavorite();
    }

    @Override
    public boolean saveRecord(Integer userId, Long favoriteId) {
        return userFavoriteRepository.saveRecord(userId,favoriteId);
    }

    @Override
    public boolean checkBelong(Integer userId, Long favId) {
        return userFavoriteRepository.checkBelong(userId,favId);
    }

    @Override
    public Pair<List<Long>, Long> selectPageByFavId(Long favId, PageDTO pageDTO) {
        return favoriteRepository.selectContentIdPageByFavId(favId,pageDTO.getCurPage(),pageDTO.getPageNum());
    }

    @Override
    public List<FavoritesIntroVO> selectFavInfo(List<Long> ids, boolean equals) {
        return favoriteRepository.selectFavInfo(ids,equals);
    }
}
